package com.heima.controller;


import com.heima.pojo.dto.RegionDto;
import com.heima.pojo.dto.RegionSearchDto;
import com.heima.pojo.vo.RegionSearchVO;
import com.heima.service.RegionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 运营区域 前端控制器
 * </p>
 *
 * @author ljk
 * @since 2024-10-15
 */
@RestController
@RequestMapping("/api/vm-service/region")
@Api(tags = "区域相关接口")
@Slf4j
@RequiredArgsConstructor
public class RegionController {
    private final RegionService regionService;

    @GetMapping("/search")
    @ApiOperation("区域列表查询")
    public RegionSearchVO pageQuery(RegionSearchDto regionSearchDto){
        return regionService.pageQuery(regionSearchDto);
    }

    @PostMapping
    @ApiOperation("新增区域")
    public Boolean addRegion(@RequestBody RegionDto regionDto){
        regionService.addRegion(regionDto);
        return true;
    }

    @PutMapping("/{regionId}")
    @ApiOperation("修改区域")
    public Boolean updateRegion(@PathVariable String regionId,@RequestBody RegionDto regionDto){
        regionService.updateRegion(regionId,regionDto);
        return true;
    }

    @DeleteMapping("/{regionId}")
    @ApiOperation("删除区域")
    public Boolean delById(@PathVariable String regionId){
        regionService.delById(regionId);
        return true;
    }
}
